<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.1.0.js"></script>
<script type="text/javascript">
	$(function(){
			$("#insertBtn").click(function(){
				if($("#title").val()==""){
					alert("제목 입력!");
					return false;
				}else if($("#content").val()==""){
					alert("글 입력!");
					return false;
				}
		});		
	
			//select 선택 시
		$(":input[name=kind]").change(function(){
				 var t=$("#title").val();
				
			 if($(this).val()=='공지사항'){
					$("#kindTitleView").html("");
					$("#kindTitleView").html("<input type=text class=form-control id=title name=title value='[공지] "+t+" '>");
				}else if($(this).val()=='일반게시글'){
					$("#kindTitleView").html("");
					$("#kindTitleView").html("<input type=text class=form-control id=title name=title>");
				} 
	});
	
	});
	
	function cancel(){
		alert("작성 취소");
		location.href=${initParam.root }+"getContentListPerPage.ju?nowPage=1";
	}
</script>
</head>

<body>
<form method="post" name="writeForm" action="${initParam.root }freeWriteContent.ju">
<input type="hidden" id="memberVO.id" name="memberVO.id" value="${sessionScope.mvo.id}">
<input type="hidden" id="memberVO.nickname" name="memberVO.nickname" value="${sessionScope.mvo.nickname}">
	
<fieldset>
    <legend> Free Board 글쓰기</legend>    

			<div class="form-group">
				<label for="title" class="col-lg-2 control-label">제목</label>
				<div class="col-lg-10" id="kindTitleView">
						<input type="text" class="form-control"  id="title" name="title">
						<c:if test="${sessionScope.mvo.grade=='user'}">
						<input type="hidden" id="kind" name="kind" value="일반게시글">
						</c:if>
				<br>
				</div>
			</div>

			<c:if test="${sessionScope.mvo.grade=='admin'}">
	<div id="selectView" class="form-group">
      <label for="kind" class="col-lg-2 control-label">글 분류</label>
      <div class="col-lg-10">			
						<select id="kind" name="kind" class="form-control" >
								<option value="일반게시글">일반게시글</option>
								<option value="공지사항">공지사항</option>
						</select>	
						<br>			
      </div>
    </div> 
</c:if>
  	
    <div class="form-group">
      <label for="textArea" class="col-lg-2 control-label">내용</label>
      <div class="col-lg-10">
        <textarea class="form-control" rows="5" id="content" name="content"></textarea>
      </div>
    </div> 
    
    <div class="form-group">
      <div class="col-lg-10 col-lg-offset-2" align="center">
      <br>
<!--  <input type="submit" id="insertBtn" value="작성"> -->
<!-- <input type="button"onclick="cancel()" value="취소"> -->
<input type="image" id="insertBtn" src="${initParam.root }img/okbtn.png" height="25px">
<img src="${initParam.root }img/cancelBtn.png" height="25px"  id="listBtn"  onclick="cancel()" style="margin-top: -20px">
<br>
      </div>
    </div>
    
  </fieldset>
 </form> 
 
</body>
</html>